import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    // 重定向到登陆页面
    redirect:'/login',
    component: Home
  },
  // 登陆页面的路由
  {
    path:'/login',
    name:'login',
    component:()=>import('@/pages/login.vue')
  },
  {
    path:'/manager',
    name:'manager',
    component:()=>import('@/pages/manager.vue'),
    children:[
      {
        path:'home',
        name:'Home',
        component:()=>import('@/pages/home.vue')
      },
      {
        path:'order',
        name:'Order',
        component:()=>import('@/pages/order.vue')
      },
      {
        path:'help',
        name:'Help',
        component:()=>import('@/pages/help.vue')
      },
      {
        path:'user',
        name:'User',
        component:()=>import('@/pages/user.vue'),
      },
      {
        path:'productList',
        name:'productList',
        component:()=>import('@/pages/productList.vue')
       },
       {
        path:'address',
        name:'address',
        component:()=>import('@/pages/address.vue')
      },
      {
        path:'submit',
        name:'submit',
        component:()=>import('@/pages/submit.vue')
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
